<%@ page pageEncoding="UTF-8"%>
<%!
    public Message queryGroup(DoctorGroup doctorGroup) {
        Message msg = new Message();
        List list = QBuilder.db("basedb").select("new map(dg.id as group_id, dg.groupName as group_name, dg.doctorUid as doctor_uid, dg.content as content, count(gp.id) as num)").from("DoctorGroup as dg, GroupPatient as gp").where(new Where("dg.id = gp.groupId").and("dg.doctorUid = ",doctorGroup.getDoctorUid()).and("dg.status = ", STATUS_ENABLE).and("gp.status = ", STATUS_ENABLE).and("dg.hospital = ", doctorGroup.getHospital()).and("gp.hospital = ", doctorGroup.getHospital())).group("gp.groupId").query().getResultObj();

        List list_total = QBuilder.db("basedb").select("new map(id as group_id, groupName as group_name, doctorUid as doctor_uid, content as content)").from("DoctorGroup").where(new Where("doctorUid =", doctorGroup.getDoctorUid()).and("status = ", STATUS_ENABLE).and("hospital =", doctorGroup.getHospital())).query().getResultObj();

        if (isEmpty(list_total)) {
            msg = new Message(30041, "暂未创建分组");
            return msg;
        }
        for (int i = 0; i < list_total.size(); i ++) {
            Map dg = (Map)list_total.get(i);
            int id = Tools.getInt(dg.get("group_id") + "");
            boolean isAdd = true;
            for (int j = 0; j < list.size(); j ++) {
                if (id == Tools.getInt(((Map)list.get(j)).get("group_id") + "")) {
                    isAdd = false;
                    break;
                }
            }
            if (isAdd) {
                dg.put("num", 0);
                list.add(dg);
            }
        }
        msg.put("data",list);
        return msg;
    }
%>
